﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;

namespace ExpressionUtil.Node.Common
{
    /// <summary>
    /// 函数节点
    /// </summary>
    internal abstract class FunctionNode : Common.Node, ISerializable
    {
        /// <summary>
        /// 参数列表
        /// </summary>
        private List<Node> parameters;

        /// <summary>
        /// 默认构造函数
        /// </summary>
        public FunctionNode()
            : base()
        {
            this.parameters = new List<Node>();
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="info">要填充数据的 System.Runtime.Serialization.SerializationInfo</param>
        /// <param name="context">此序列化的目标</param>
        public FunctionNode(SerializationInfo info, StreamingContext context)
            : base()
        {
            this.parameters = (List<Node>)info.GetValue("parameters", typeof(List<Node>));
        }

        /// <summary>
        /// 获取或设置参数列表
        /// </summary>
        public List<Common.Node> Parameters
        {
            get
            {
                return this.parameters;
            }
        }

        #region ISerializable 成员
        /// <summary>
        /// 获取对象数据
        /// </summary>
        /// <param name="info">要填充数据的 System.Runtime.Serialization.SerializationInfo</param>
        /// <param name="context">此序列化的目标</param>
        public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue("parameters", this.parameters, typeof(List<Node>));
        }

        #endregion
    }
}
